﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeaBattle.Domain.Abstract.Services;
using SeaBattle.Domain.Entities;

namespace SeaBattle.Domain.Concrete.Services
{
    public class FakeAccountService: IAccountService
    {
        private IPlayerService PlayerService;

        private static List<Account> accountRests= new List<Account>{
            new Account(10000,"vasya"),
            new Account(900,"alex"),
            new Account(2000,"andrew")
        };

        public FakeAccountService(IPlayerService PlayerService)
        {
            this.PlayerService = PlayerService;
        }

        public decimal GetPlayerBalance(Player player)
        {
            return GetPlayerBalance(player.Login);
        }

        public decimal GetPlayerBalance(string Login)
        {
            var Account = accountRests.FirstOrDefault(x => x.OwnerLogin == Login);
            if (Account!=null)
            {
                return Account.Balance;
            }
            throw new Exception("Player with login " + Login + " hasnt any balance");
        }


        public Account GetPlayerAccount(string login)
        {
            var Account = accountRests.FirstOrDefault(x => x.OwnerLogin == login);
            if (Account != null)
            {
                return Account;
            }
            throw new Exception("Player with login " + login + " hasnt any balance");
        }
    }
}
